﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PontoDeVenda
{
    public partial class JanelaCliente : ChildWindow
    {

        void proxy_GetClientePorIdCompleted(object sender, 
            DataServiceReference.GetClientePorIdCompletedEventArgs e)
        {
            DataServiceReference.Cliente cliente = e.Result;
            this.LayoutRoot.DataContext = e.Result;
        }


        public JanelaCliente()
        {
            InitializeComponent();


        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void btnInserirCliente_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnAtualizarCliente_Click(object sender, RoutedEventArgs e)
        {

        }

        private void btnExcluirCliente_Click(object sender, RoutedEventArgs e)
        {

        }

        private void GetCliente_Click(object sender, RoutedEventArgs e)
        {
            txtMensagemStatus.Text = "";
            try
            {
                int clienteId = Convert.ToInt16(txtClienteID.Text);
                DataServiceReference.DataServiceClient proxy = new
                    DataServiceReference.DataServiceClient();
                proxy.GetClientePorIdCompleted += new
                    EventHandler<DataServiceReference
                    .GetClientePorIdCompletedEventArgs>(proxy_GetClientePorIdCompleted);
                proxy.GetClientePorIdAsync(clienteId);


            }
            catch (Exception erro)
            {
                txtMensagemStatus.Text = "ERRO: " + erro.Message;
            }

 
        }
    }
}

